#pragma once
#include <list>

namespace JHCPP
{
	namespace utils
	{
		template <typename T>
		class TAutoReleasePool
		{
		public:
			TAutoReleasePool()
			{
			}

			~TAutoReleasePool()
			{
				release();
			}

			void add(T* pObject)
			{
				if (pObject)
					m_list.push_back(pObject);
			}

			void release()
			{
				while (!m_list.empty())
				{
					m_list.front()->release();
					m_list.pop_front();
				}
			}

		private:
			typedef std::list<T*> ObjectList;
			ObjectList m_list;
		};
	}//end of namespace utils
}//end of namespace JHCPP
